package View.UsuarioView;

import java.awt.Dimension;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;

import Controller.UsuarioController.UsuarioController;
import Entidade.Usuario;
import framework.component.field.TTextField;
import framework.mvc.GenericView;
import javax.swing.SwingConstants;
import java.awt.Component;

public class UsuarioView extends GenericView<Usuario> {

	private static final long serialVersionUID = 4336484736659111880L;
	private TTextField textField;
	private TTextField textField_1;

	public UsuarioView() {
		super(new UsuarioController());
		setResizable(false);
		setTitle("Fox Empresarial - Cadastro de Usuarios");
		setSize(new Dimension(371, 145));
		
		JLabel lblUsuario = new JLabel("Usuario");
		
		JLabel lblSenha = new JLabel("Senha");
		
		textField = new TTextField();
		textField.setName("NomeUsuario");
		textField.setColumns(10);
		
		textField_1 = new TTextField();
		textField_1.setName("SenhaUsuario");
		textField_1.setColumns(10);
		
		JButton button = new JButton("Salvar");
		button.setName("salvar");
		
		JButton button_1 = new JButton("Cancelar");
		button_1.setName("cancelar");
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(button, GroupLayout.PREFERRED_SIZE, 92, GroupLayout.PREFERRED_SIZE)
							.addGap(8)
							.addComponent(button_1, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblSenha)
								.addComponent(lblUsuario))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(textField, GroupLayout.PREFERRED_SIZE, 270, GroupLayout.PREFERRED_SIZE)
								.addComponent(textField_1, 268, 268, 268))))
					.addContainerGap(13, Short.MAX_VALUE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblUsuario)
						.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblSenha)
						.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(button_1)
						.addComponent(button))
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		groupLayout.linkSize(SwingConstants.VERTICAL, new Component[] {lblUsuario, lblSenha});
		groupLayout.linkSize(SwingConstants.VERTICAL, new Component[] {textField, textField_1});
		groupLayout.linkSize(SwingConstants.VERTICAL, new Component[] {button, button_1});
		groupLayout.linkSize(SwingConstants.HORIZONTAL, new Component[] {lblUsuario, lblSenha});
		groupLayout.linkSize(SwingConstants.HORIZONTAL, new Component[] {textField, textField_1});
		groupLayout.linkSize(SwingConstants.HORIZONTAL, new Component[] {button, button_1});
		getContentPane().setLayout(groupLayout);
	}
}
